//
// Created by ZLY on 2025/5/11.
//

#ifndef HUD_TEXT_H
#define HUD_TEXT_H
#include "../affiliate/sprite.h"
#include "../affiliate/text_label.h"
#include "../core/object_screen.h"


class HUDText : public ObjectScreen {
protected:
    TextLabel *text_label_ = nullptr;
    Sprite *sprite_bg_ = nullptr;
    glm::vec2 size_ = glm::vec2(0);

public:
    static HUDText *addHUDTextChild(Object *parent, const std::string &text, glm::vec2 size,
                                    glm::vec2 render_pos,
                                    const std::string &font_path = "resources/font/VonwaonBitmap-16px.ttf",
                                    int font_size = 16,
                                    const std::string &bg_path = "resources/UI/Textfield_01.png",
                                    Anchor anchor = Anchor::CENTER);

    void setBgSizeByText(float margin = 10.0f);

    void setTextLabel(TextLabel *text_label) {
        this->text_label_ = text_label;
    }

    void setSprite(Sprite *sprite) {
        this->sprite_bg_ = sprite;
    }

    Sprite *getSprite() {
        return sprite_bg_;
    }

    TextLabel *getTextLabel() {
        return text_label_;
    }

    void setText(const std::string &text) {
        text_label_->setTTFText(text);
    }

    std::string getText() {
        return text_label_->getTTFText();
    }

    void setSize(glm::vec2 size);

    void setBackGround(const std::string &file_path);
};


#endif //HUD_TEXT_H
